//
//  KuaidiModel.swift
//  Pods
//
//  Created by eme on 2017/3/31.
//
//

import Foundation
import SwiftyJSON
import NetWorkCore
import ModelProtocol

class KuaidiModel: ModelProtocol {
    
    // MARK: Declaration for string constants to be used to decode and also serialize.
    internal let kKuaidiStatusKey: String = "status"
    internal let kKuaidiResultKey: String = "result"
    internal let kKuaidiMsgKey: String = "msg"
    internal let kdeliverystatusMsgKey: String = "deliverystatus"
    
    
    // MARK: 属性
    var status: String
    var result: ResultModel
    var msg: String
    var deliverystatus:String
    
    
    // MARK: 实现MikerSwiftJSONAble 协议， 解析json数据
    required  init?(json: JSON) {
        status = json[kKuaidiStatusKey].stringValue
        result = ResultModel(json: json[kKuaidiResultKey])!
        msg = json[kKuaidiMsgKey].stringValue
        deliverystatus = json[kdeliverystatusMsgKey].stringValue
    }
    
    
    /**
     Generates description of the object in the form of a NSDictionary.
     - returns: A Key value pair containing all valid values in the object.
     */
    internal func dictionaryRepresentation() -> [String : AnyObject ] {
        
        var dictionary: [String : AnyObject ] = [ : ]
        
            dictionary.updateValue(status as AnyObject, forKey: kKuaidiStatusKey)
        
        
            dictionary.updateValue(result.dictionaryRepresentation() as AnyObject, forKey: kKuaidiResultKey)
        
        
            dictionary.updateValue(msg as AnyObject, forKey: kKuaidiMsgKey)
        
       
            dictionary.updateValue(deliverystatus as AnyObject, forKey: kdeliverystatusMsgKey)
        
        
        return dictionary
    }
    
    
}
